package com.siwen.controller;

import com.siwen.pojo.ChildTbl;
import com.siwen.pojo.system.ModuleResult;
import com.siwen.pojo.system.SysAdminRole;
import com.siwen.pojo.system.SysModule;
import com.siwen.result.ChildTblResult;
import com.siwen.service.SystemService;
import jdk.nashorn.internal.ir.RuntimeNode;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.annotation.RequestScope;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/sys")
@CrossOrigin

public class SystemController {


    @Resource
    private SystemService systemService;

    @GetMapping("/TheMenuAll")
    public List<ModuleResult> TheMenuAll(){

      return  systemService.TheMenuAll();
    }
    @GetMapping("/ChildTblAll")
    public ChildTblResult ChildTblAll(long page,int limit,String authenname ,String startTime,String endTime){

            return  systemService.ChildTblAll(page,limit,authenname,startTime,endTime);
    }

    @PostMapping("/updateChildTblById")
    public ChildTblResult updateChildTblById(ChildTbl c){
        System.out.println( c.toString());


        return  systemService.updateChildTblById(c);
    }
    @PostMapping("/deleteChildTblById")
    public  ChildTblResult deleteChildTblById(@RequestParam("id") String  id,@RequestParam("adminid") String  adminid){
        System.out.println("---------------"+id);
        return systemService.deleteChildTblById(id,adminid);

    }
    @PostMapping("/sysLogin")
    public  ChildTblResult sysLogin(String admincode, String password,String ip, HttpSession session){


        return  systemService.sysLogin(admincode,password,ip);
    }
    @PostMapping("/insertChildTbl")
    public  ChildTblResult insertChildTbl(ChildTbl c){
        System.out.println(c.toString());
        return systemService.insertChildTbl(c);
    }
    @RequestMapping("/cs")
    public  List<SysAdminRole> sc(String id){
        return  systemService.selectSysAdminRoleByid(id);
    }
}
